/**
 * 
 */
package com.angel.configuration;

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

/**
 * @author William
 *
 */
public class BusinessAdapterConfiguration {
	  /**
     * @return the configuration entries
     */
    public Map<String, String> getEntries() {
        return JFigAdapterConfiguration.INSTANCE.getEntries();
    }


    /**
     * @param _section section
     * @param _key     key
     * @return a boolean that represents a value of configuration
     */
    public boolean getBoolean(final String _section, final String _key) {
        return JFigAdapterConfiguration.INSTANCE.getBoolean(_section, _key);
    }


    public Properties getSectionAsProperties(final String _sectionName) {
        return JFigAdapterConfiguration.INSTANCE.getSectionAsProperties(_sectionName);
    }


    /**
     * @param _key     the key
     * @param _section the section
     * @return a float that represents a value of configuration
     */
    public float getFloat(final String _section, final String _key) {
        return JFigAdapterConfiguration.INSTANCE.getFloat(_section, _key);
    }


    /**
     * @param _key     the key
     * @param _section the section
     * @return an int that represents a value of configuration
     */
    public int getInt(final String _section, final String _key) {
        return JFigAdapterConfiguration.INSTANCE.getInt(_section, _key);
    }


    /**
     * @param _key     the key
     * @param _section the section
     * @return a String that represents a value of configuration
     */
    public String getString(final String _section, final String _key) {
        return JFigAdapterConfiguration.INSTANCE.getString(_section, _key);
    }


    /**
     * @param _key     the key
     * @param _section the section
     * @return Return a map of all values starting with "key" in the section.
     */
    public Map<String, String> getStartingWith(final String _section, final String _key) {
        return JFigAdapterConfiguration.INSTANCE.getStartingWith(_section, _key);
    }


    /**
     * Convenience method for getting values as array.
     *
     * @param _key     the key
     * @param _section the section
     * @return an array with all values in Section, key
     */
    public String[] getArray(final String _section, final String _key) {
        return JFigAdapterConfiguration.INSTANCE.getArray(_section, _key);
    }


    /**
     * @return a convenient  String with all values
     */
    public String toString() {
        final StringBuffer _stringBuffer = new StringBuffer(this.getClass().toString());
        _stringBuffer.append("\n");

        final Iterator<Map.Entry<String, String>> iterator = JFigAdapterConfiguration.INSTANCE.getEntries().entrySet().iterator();
        while (iterator.hasNext()) {
            final Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next();
            final Object key = entry.getKey();
            final Object value = entry.getValue();

            _stringBuffer.append(key);
            _stringBuffer.append(value);
            _stringBuffer.append("\n");
        }
        return _stringBuffer.toString();
    }

    public void reprocessConfiguration() {
        JFigAdapterConfiguration.INSTANCE.reprocessConfiguration();
    }


}
